-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Disable autogenerate session id #21886
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files🚀 New features to boost your workflow:
|
624bfd2 to
f15e379
Compare
f15e379 to
68d1ce7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @toillium ! I am not 100% sure why this would be an issue since as far as I can tell the check runs synchronously. Would you mind sharing where do you think the multi-threaded behavior is?
The error you report seeing is
HTTPDriver for <URL> received ClickHouse error code 373\n Code: 373. DB::Exception: Session 7de98854-bff0-481b-a959-aa18f3ec9e4d is locked by a concurrent client. (SESSION_IS_LOCKED)
This means that the error is coming from the server returning 373 right? Is it possible that somehow the query launched against clickhouse is timing out somehow but we reuse the client and launch a new query against the server, causing the session already used error?
I am bit worried that by not generating the session ID we might be hiding an issue with timeouts for instance that we should be resurfacing to customers.
My Feedback Legend
Here's a quick guide to the prefixes I use in my comments:
praise: no action needed, just celebrate!
note: just a comment/information, no need to take any action.
question: I need clarification or I'm seeking to understand your approach.
nit: A minor, non-blocking issue (e.g., style, typo). Feel free to ignore.
suggestion: I'm proposing an improvement. This is optional but recommended.
request: A change I believe is necessary before this can be merged.
The only blocking comments are request, any other type of comment can be applied at discretion of the developer.
I think the multithreaded behavior is coming from datadog agent's query scheduling.
I think the issue is query A launches with session id
I don't think session id impacts how timeouts are surfaced. My understanding is that it's only used to determine the lifespan of temporary resource on the clickhouse server (e.g. temporary tables). |
9fe1a22 to
9cc9c01
Compare
37e509e to
3b6a98e
Compare
|
Hi all, Joe from clickhouse here (maintainer of clickhouse-connect). Setting Hope that helps! Happy to help provide more context or answer any other clickhouse-connect questions as well. |
|
Thanks guys!
That is my point, the agent itself does not manage any queries, this is done at an integration level and the integration itself is synchronous. What I am afraid is happening is the following, @joe-clickhouse maybe you can correct me if this is not how the client behaves.
I am not sure if clickhouse will cancel ongoing queries if the client timesout. I have worked with datastores where a query is not cancelled if the client disconnects, or marked as stale. In a sense, if we call the datastore we can run into a scenario in which a pending query is blocking the session. If this is possible with clickhouse I am worried that the customers are having queries timing out they do not know about. That is what I would try address. @joe-clickhouse do you think this is possible? While removing the session id generation is a fix for the errors, we should get it merged, I would like to understand if this is scenario is possible and we should improve our error handling. Also, if there is any way to ensure clickhouse cancels an ongoing query. These could start accumulating generating load on the cluster for queries that no one is going to listen to. |
|
Hi @AAraKKe, yes this definitely a possible scenario. So if that's the use case, then this is definitely a valid concern. So, in it's current state if we assume this scenario:
This will cause new queries to collide with the still-running queries and raise That said, @AAraKKe your instinct is correct and if the client times out the sever will not (by default) cancel the query so query accumulation is a valid concern in this case if you're having client connection/timeout issues and submitting the same thing multiple times. There are a few things we could do to mitigate these kinds of potential issues however:
Side note, I think your scenario is just theoretical but the default client-side timeout default is 5 minutes. I think it'd be pretty rare for correctly designed and working queries to regularly hit that limit so if for some reason they are, it's worth a different discussion. Hope that helps! |
|
Thanks @joe-clickhouse! I appreciate your help with this, I will follow up with the team and come up with a solution. What I am thinking would be the best approach is:
Regarding the default timeout, that is the default on the I am approving the PR to prevent the Thanks guys! |
What does this PR do?
Makes the clickhouse client thread safe by disabling
autogenerate_session_id.Relevant docs: https://clickhouse.com/docs/integrations/language-clients/python/driver-api#multi-threaded-applications
Motivation
#21885